package controller.main
{
	import events.main.EventBrowseForFiles;
	
	import model.ModelBrowseFile;
	import model.ModelProject;
	
	import org.robotlegs.mvcs.Command;
	
	import services.IServiceBrowseForFiles;
	
	public class CommandBrowseForFile extends Command
	{
		[Inject]
		public var mb:ModelBrowseFile;
		
		[Inject]
		public var mp:ModelProject;
		
		[Inject]
		public var e:EventBrowseForFiles;
		
		[Inject]
		public var sb:IServiceBrowseForFiles;
		
		override public function execute() : void {
			mb.currentBrowseType = e.identifier;
			mb.imageIdToUpdate = e.imageIdToUpdate;
			mb.binaryIdToUpdate = e.binaryIdToUpdate;
			switch (e.identifier){
				case mb.BROWSE_FOR_OPEN_IMAGES:
					sb.browseForOpenMultiple(mb.imagesExtenstions);
					break;
				case mb.BROWSE_FOR_UPDATE_IMAGE:
					sb.browseForOpen(mb.imagesExtenstions);
					break;
				case mb.BROWSE_FOR_OPEN_BINARIES:
					sb.browseForOpenMultiple();
					break;
				case mb.BROWSE_FOR_UPDATE_BINARY:
					sb.browseForOpen();
					break;
				case mb.BROWSE_FOR_SAVE_PROJECT:
					sb.browseForSave(mp.projectName + (mb.projectExtension[1] as String).substr(1));
					break;
				case mb.BROWSE_FOR_LOAD_PROJECT:
					sb.browseForOpen(mb.projectExtension);
					break;
			}
		}
	}
}